function [all_theta] = oneVsAll(X, y, num_labels, lambda)
    %   Get the rows and columns of the data
    [m, n] = size(X);
    %   The result which will be returned.
    all_theta = zeros(num_labels, n + 1);
    %   Add a column of ones to the data
    X = [ones(m, 1), X];
    %   The initial thetas
    initial_theta = zeros(n + 1, 1);
    %   Options for fmincg
    options = optimset('GradObj', 'on', 'MaxIter', 50);
    %   Train the thetas
    for i = 1:num_labels
        all_theta(i, :) = fmincg(@(t)(lrCostFunction(t, X, (y == i), lambda)), initial_theta, options);
    end
end
